package com.zw.yzk.kabu.data.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by zhanwei on 2017/1/4.
 */

public class AppUtils {

    //获取应用包名
    public static String getPackageName(Context context) {
        return context.getPackageName();
    }

    //获取应用版本号
    public static int getAppVersionCode(Context context) {
        int currentVersionCode = 0;
        PackageManager manager = context.getPackageManager();
        try {
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            currentVersionCode = info.versionCode; // 版本号
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return currentVersionCode;
    }
}
